local osFenwang = fk.CreateSkill {
  name = "md__fenwang",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["md__fenwang"] = "焚亡",
  [":md__fenwang"] = "锁定技，①当你受到属性伤害时，你须弃置一张手牌，否则此伤害+1。②当你对其他角色造成普通伤害时，若你的手牌数不小于其手牌数，此伤害+1。",

  ["#md__fenwang-discard"] = "焚亡：弃置一张手牌，否则此伤害+1",

  ["$md__fenwang1"] = "洛阳逢此大难，吾，亦难脱身。",
  ["$md__fenwang2"] = "大火之下，黑影，已无所遁形！",
}

osFenwang:addEffect(fk.DamageInflicted, {
  can_trigger = function(self, event, target, player, data)
    if target ~= player or not player:hasSkill(osFenwang.name) then return end
    return data.damageType ~= fk.NormalDamage
  end,
  on_use = function(self, event, target, player, data)
    ---@type string
    local skillName = osFenwang.name
    local room = player.room
    room:notifySkillInvoked(player, skillName, "negative")
    player:broadcastSkillInvoke(skillName, 1)
    local ids = player.room:askToDiscard(player, {
      min_num = 1,
      max_num = 1,
      include_equip = false,
      skill_name = skillName,
      cancelable = true,
      prompt = "#md__fenwang-discard",
    })
    if #ids == 0 then
      data:changeDamage(1)
    end
  end,
})

osFenwang:addEffect(fk.DamageCaused, {
  mute = true,
  can_trigger = function(self, event, target, player, data)
    if target ~= player or not player:hasSkill(osFenwang.name) then return end
    return data.damageType == fk.NormalDamage and player:getHandcardNum() >= data.to:getHandcardNum()
  end,
  on_use = function(self, event, target, player, data)
    ---@type string
    local skillName = osFenwang.name
    local room = player.room
    room:notifySkillInvoked(player, skillName, "offensive")
    player:broadcastSkillInvoke(skillName, 2)
    data:changeDamage(1)
  end,
})

return osFenwang
